/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.catosist.run.business.gestorcolores;

import com.catosist.run.dataaccess.domain.ColoresDao;
import com.catosist.run.dataaccess.model.ColoresVO;
import com.catosist.run.services.ColoresDTO;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

/**
 *
 * @author Carlos
 */
public class GestorColoresImpl implements GestorColores{

    public GestorColoresImpl(){

    }


     @Override
     public List<ColoresDTO> getAll() {
        if (coloresVOs == null) {
            coloresVOs = coloresDao.getAll();
        }
        List<ColoresDTO> coloresDTOs = new LinkedList<ColoresDTO>();
        for (Iterator<ColoresVO> it = coloresVOs.iterator(); it.hasNext();) {
            ColoresVO coloresVO = it.next();
            coloresDTOs.add(new ColoresDTO(coloresVO.getId(),
                    coloresVO.getNombre()));
        }
        return coloresDTOs;
    }

//    @Override
//    public ColoresDTO get(int indice) {
//        ColoresVO coloresVO = getVOatIndex(indice);
//        return new ColoresDTO(coloresVO.getId(),
//                coloresVO.getNombre());
//    }

    
    public ColoresVO getVOatIndex(int indice) {
        return coloresVOs.get(indice);
    }


    
    public ColoresDao getColoresDao() {
        return coloresDao;
    }
    
    
    public void setColoresDao(ColoresDao coloresDao) {
        this.coloresDao = coloresDao;
    }

    @Override
    public void deleteById(int Id) {
        ColoresVO coloresVO = new ColoresVO();
        coloresVO.setId(Id);
        coloresDao.deleteById(Id);
    }

    @Override
    public int getIdAtIndex(int indice) {
        return getVOatIndex(indice).getId();
    }


    @Override
    public ColoresDTO getById(int voId) {
        return null;
    }

    @Override
    public void saveOrUpdate(ColoresDTO o) {


    }

     @Override
    public ColoresDTO getByIndex(int indice) {
        ColoresVO coloresVO = this.coloresVOs.get(indice);
        ColoresDTO tmp = new ColoresDTO(indice, null);
//        ColoresDTO tmp = new ColoresDTO(coloresVO.getId(), viajeVO.getRuta().getDescripcion(),
//                viajeVO.getPersona().getNombre(), viajeVO.getVehiculo().getPlaca());
        return tmp;
    }
    private List<ColoresVO> coloresVOs;
    private ColoresDao coloresDao ;

    @Override
    public void updateListVo() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public int getIndexOf(int voId) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public void deleteByIndex(int index) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

}
